var app = getApp();
Page({
  // 15冲床(冲床员工) 17定钉（定钉员工） 18整形 19压支架 20压铆钉 21焊袖套 22拉床 23打珠 24包装
  data: {
    hArray: [
      {
        hou: 15,
        name: '冲床'
      },
      {
        hou: 17,
        name: '定钉'
      },
      {
        hou: 18,
        name: '整形'
      },
      {
        hou: 19,
        name: '压支架'
      },
      {
        hou: 20,
        name: '压铆钉'
      },
      {
        hou: 21,
        name: '焊袖套'
      },
      {
        hou: 22,
        name: '拉床'
      },
      {
        hou: 23,
        name: '打珠'
      },
      {
        hou: 24,
        name: '包装'
      }
    ],
    hindex: 0,
    hname:'点击选择工序',
    pageInfo: '',
    index: 0,   
    zzz:'2',
    date: '',
    banci:'',
    choose:'',
    info:[],
    id:'',
    showgif:false,
  },

  onLoad: function () {
    var that = this;
    if (!wx.getStorageSync('openid')) {
      app.error("请登录后再操作");
      return false;
    }
  
  },
  onShow:function(){
  },
 //角色变更事件
bindPickerChange_hx(e) {
  console.log('picker发送选择改变，索引为', e.detail.value);
　var hname = this.data.hArray[e.detail.value].name //根据索引去查对应的id
　var hindex = this.data.hArray[e.detail.value].hou //根据索引去查对应的id
  this.setData({   //给变量赋值
      hindex: hindex,
      hname:hname
  })
},
 

  formSubmit: function (event) {
    var that = this;
    if (event.detail.value.pid) {
        if(!(/(^[0-9]*$)/.test(event.detail.value.pid))){
          app.error('配置ID只能是数字');
          return;
        }
    }else{
      app.error('请输入配置ID');
      return;
    }

    if (event.detail.value.page) {
      if(!(/(^[0-9]*$)/.test(event.detail.value.page))){
        app.error('工序卡页码只能是数字');
        return;
      }
    }else{
      app.error('请输入工序卡页码');
      return;
    }

    if (that.data.hindex == 0) {
      app.error('请选择工序');
      return;
    } 

     var pid = event.detail.value.pid;
     var page = event.detail.value.page;
     var working = that.data.hindex;
     that.setData({   //给变量赋值
      showgif: true,
     })

      wx.request({
        url: app.apiUrl + '/api/data/searchinfo',
        data: {
          pid:pid,
          page:page,
          openid:wx.getStorageSync('openid'),
          working:working
        },
        method: 'POST',
        header: { 'content-type': 'application/x-www-form-urlencoded' },
        success: res=> {
          that.setData({   //给变量赋值
            showgif: false,
           })

         if(res.data.code == 1){
          that.setData({   //给变量赋值
            zzz: 1,
            info:res.data.data
           })
 
         }else{
          that.setData({   //给变量赋值
            zzz: 2,
            info:[]
           })
          wx.showModal({
            title: '温馨提示',
            content: res.data.msg,
            showCancel: false
          });
         }
  
        }
      })
   


  },


})